<template>
  <div>
    <div class="jl_form" @click="click">
      <div class="jl_form_item bor_bottom">
        <span class="w04" style="color: gray"><em class="font_red" v-if="required">*</em>{{label}}</span>
        <span class="w08 tr">{{value}}</span>
        <i class="fa fa-calendar"></i>
      </div>
    </div>
    <nut-datepicker
      :is-visible="isShow"
      :type="type"
      :title="title"
      :startDate="startDate"
      :endDate="endDate"
      @choose="ok"
      @close="close"
    ></nut-datepicker>
  </div>
</template>

<script>
  export default {
    name: 'jl-from-datepicker',
    props: {
      label: { type: String },
      title: { type: String },
      required: {
        type: Boolean,
        default: false
      },
      type: {
        type: String,
        default: 'date' // 类型，日期'date'， 日期时间'datetime'，时间'time'
      },
      value: { type: String }
    },
    data() {
      return {
        isShow: false,
        startDate: '',
        endDate: ''
      }
    },
    methods: {
      click() {
        this.isShow = true
      },
      ok(o) {
        let res = o[3]
        this.$emit('input', res)
      },
      close() {
        this.isShow = false
      }
    },
    created() {
      this.startDate = $Utils.getDate()
      this.endDate = $Utils.getYear(2, 'yyyy-MM-dd')
    }
  }
</script>

<style scoped>
</style>
